package com.thyme.system.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.thyme.system.vo.Iec61850DataInstVo;
import com.thyme.system.vo.Iec61850NodeDataVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author nana
 * @since 2021-03-17
 */
public interface Iec61850DataInstDao extends BaseMapper<Iec61850DataInstVo> {

    @Delete("delete from iec61850_data_inst where iec61850_ied_inst_id = #{iec61850IedInstId}")
    int deleteByIec61850IedInstId(@Param("iec61850IedInstId") Integer iec61850IedInstId);

    @Select("  SELECT f.*,d.ied_name  FROM (SELECT * FROM iec61850_data_inst WHERE iec61850_ied_inst_id=#{iedId}) f left join iec61850_ied_inst d  on f.iec61850_ied_inst_id=d.id ")
    IPage<Iec61850NodeDataVo> getAll(Page page,@Param("iedId")Integer iedId);
}
